package com.umgsai.thread.thread12;

public class MyService {
	public MyOneList addServiceMethod(MyOneList list, String data) {
		try {
			synchronized (list) {
				if (list.getSize() < 1) {
					System.out.println(System.currentTimeMillis() + Thread.currentThread().getName() + " start to get data from remote server");
					Thread.sleep(2000);//模拟从远程取数据
					System.out.println(System.currentTimeMillis() + Thread.currentThread().getName() + " finisd getting data from remote server");
					list.add(data);
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return list;
	}
}
